// (c) Copyright 2013-2014 Stephen Gold <sgold@sonic.net>
// Distributed under the terms of the GNU General Public License

/*
 This file is part of the Bats Game.

 The Bats Game is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by the
 Free Software Foundation, either version 3 of the License, or (at your
 option) any later version.

 The Bats Game is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.

 You should have received a copy of the GNU General Public License
 along with the Bats Game.  If not, see <http://www.gnu.org/licenses/>.
 */
package bats.control;

import com.jme3.scene.control.Control;
import java.util.logging.Logger;
import jme3utilities.controls.DelayControl;
import jme3utilities.Validate;

/**
 * A delay control used to enable other "slave" controls after a pre-set
 * simulation interval.
 * <p>
 * Each instance is disabled at creation.
 *
 * @author Stephen Gold <sgold@sonic.net>
 */
public class BatsDelayControl
        extends DelayControl {
    // *************************************************************************
    // constants

    /**
     * message logger for this class
     */
    final private static Logger logger =
            Logger.getLogger(BatsDelayControl.class.getName());
    // *************************************************************************
    // DelayControl methods

    /**
     * Enable a slave.
     *
     * @param slave to enable (not null)
     */
    @Override
    protected void enableSlave(Control slave) {
        Validate.nonNull(slave, "slave control");
        BatsControl.setEnabled(slave, true);
    }

    /**
     * Test whether a control is valid before adding it to the list of slaves.
     *
     * @param slave control to test
     * @return true if enableSlave() can enable the control, false otherwise
     */
    @Override
    protected boolean isValidSlave(Control slave) {
        boolean result = BatsControl.isValid(slave);
        return result;
    }
}